#!/usr/bin/env python
# -*- coding: utf-8 -*-

from django.contrib import admin
from documents.models import Faculty, Module, ModuleTerm, ModulePart,\
    Semester, Lecturer, Document, Item

class FacultyAdmin(admin.ModelAdmin):
    list_display = ['name', 'user', 'date']

admin.site.register(Faculty, FacultyAdmin)

class ModuleAdmin(admin.ModelAdmin):
    list_display = ['name', 'faculty', 'user', 'date']

admin.site.register(Module, ModuleAdmin)

class ModuleTermAdmin(admin.ModelAdmin):
    list_display = ['module', 'semester', 'lecturer', 'user', 'date']

admin.site.register(ModuleTerm, ModuleTermAdmin)

class ModulePartAdmin(admin.ModelAdmin):
    list_display = ['name', 'module', 'user', 'date']
    
admin.site.register(ModulePart, ModulePartAdmin)
admin.site.register(Semester)

class LecturerAdmin(admin.ModelAdmin):
    list_display = ['last_name', 'first_name', 'user']

admin.site.register(Lecturer, LecturerAdmin)

class DocumentAdmin(admin.ModelAdmin):
    fields = ['name', 'tags', 'description', 'module_part', 'module_term', 'user', 'activated']
    list_display = ['name', 'document_module', 'description', 'date']
    
    def document_module(self, obj):
        return obj.module_part.module
    document_module.short_description = 'Modul'
    
admin.site.register(Document, DocumentAdmin)

class ItemAdmin(admin.ModelAdmin):
    fields = ['comment', 'views', 'document', 'item_category', 'user', 'activated']
    list_display = ['user', 'document_module', 'document_module_part', 'document' , 'comment', 'views', 'datetime']
    
    def document_module(self, obj):
        return obj.document.module_part.module
    document_module.short_description = 'Modul'
    
    def document_module_part(self, obj):
        return obj.document.module_part
    document_module_part.short_description = 'Modul Part'
    
admin.site.register(Item, ItemAdmin)

